package net.xdclass.xdclasssky.controller;

import net.xdclass.xdclasssky.model.JsonData;
import net.xdclass.xdclasssky.model.ProductDO;
import net.xdclass.xdclasssky.service.ProductService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 小滴课堂,愿景：让技术不再难学
 *
 * @Description
 * @Author 二当家小D，微信：xdclass6
 * @Remark 有问题直接联系我，源码-笔记-技术交流群
 * @Version 1.0
 **/

@RestController
@RequestMapping("/api/product/v1")
public class ProductController {


    Logger logger = LoggerFactory.getLogger(ProductController.class);

    @Autowired
    private ProductService productService;



    @RequestMapping("list20")
    public JsonData list(){

        logger.info("这个是我们的测试数据，分布式链路追踪，小滴课堂");

        List<ProductDO> list =  productService.list();

        return JsonData.buildSuccess(list);

    }



    @GetMapping("/detail/{product_id}")
    public JsonData detail(@PathVariable("product_id") long productId){

        ProductDO productDO = productService.detail(productId);

        return JsonData.buildSuccess(productDO);

    }


}
